{extend name="default/base/base_seller" /}
{block name="seller_main"}
<div class="alert alert-block alert-info mt10"> <strong>{$Think.lang.store_sns_type}{$Think.lang.ds_colon}</strong>
    <label class="mr20">
        <input type="radio" name="sns_type" value="normal" id="sns_normal" checked="checked" class="vm mr5" />
        {$Think.lang.store_sns_normal}</label>
    <label class="mr20">
        <input type="radio" name="sns_type" value="recommend" id="sns_recommend" class="vm mr5" />
        {$Think.lang.store_sns_recommend}</label>
    <label class="mr20">
        <input type="radio" name="sns_type" value="hotsell" id="sns_hotsell" class="vm mr5" />
        {$Think.lang.store_sns_hotsell}</label>
    <label class="mr20">
        <input type="radio" name="sns_type" value="new" id="sns_new" class="vm mr5" />
        {$Think.lang.store_sns_new}</label>
</div>


        <div class="dssc-form-default" dstype="normal" style=" display: none;">
            <form method="post" action="{:url('Sellersns/store_sns_save')}" id="normal_form">
                <input type="hidden" name="type" value="2" />
                <dl>
                    <dt>{$Think.lang.store_sns_image}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <div class="dssc-upload-thumb store-sns-pic">
                            <p>
                                <img dstype="normal_img" src="{$Think.BASE_SITE_ROOT}/uploads/home/common/default_image.png"/></p>
                            <input type="hidden" name="sns_image" id="sns_image" value="" />
                        </div>
                        <div class="handle">
                            <div class="dssc-upload-btn"> <a href="javascript:void(0);"><span>
                                        <input type="file" hidefocus="true" size="1" class="input-file" name="normal_file" id="normal_file">
                                    </span>
                                    <p><i class="iconfont">&#xe733;</i>{$Think.lang.image_upload}</p>
                                </a> </div>
                            <a class="dssc-btn" dstype="get_img" href="{:url('Selleralbum/pic_list',['item'=>'store_sns_normal'])}">
                                <i class="iconfont">&#xe72a;</i>{$Think.lang.select_from_image_space}</a>
                            <a href="javascript:void(0);" dstype="del_img" class="dssc-btn ml5" style="display: none;">
                                <i class="iconfont">&#xe67a;</i>{$Think.lang.close_album}</a>
                        </div>
                        <div id="get_img_ajaxContent" class="ajax-albume"></div>
                        <p class="hint">{php}printf(lang('store_sns_normal_tips'),intval(config('ds_config.image_max_filesize'))/1024){/php}</p>
                    </dd>
                </dl>
                <dl>
                    <dt><i class="required">*</i>{$Think.lang.store_sns_cotent}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <textarea name="content" class="textarea w450 h100" id="content_normal" dstype="normal"></textarea>
                        <p class="w450">
                           <!-- <a href="javascript:void(0)" ds_type="smiliesbtn" data-param='{"txtid":"normal"}' class="dssc-btn-mini dssc-btn-orange">
                            <i class="iconfont">&#xe669;</i>{$Think.lang.store_sns_face}</a>-->
                            <span id="weibocharcount_normal" class="weibocharcount"></span>
                        </p>
                    </dd>
                </dl>
                <div class="bottom">
                    <input type="submit" class="submit" value="{$Think.lang.store_sns_release}" />
                </div>
            </form>
        </div>

        <div class="dssc-form-default" dstype="recommend" style="display: none;">
            <div class="alert">
                <h4>{$Think.lang.store_sns_explain}{$Think.lang.ds_colon}</h4>
                <ul>
                    <li>{$Think.lang.store_sns_explain_notes1}</li>
                </ul>
            </div>
            <form method="post" action="{:url('Sellersns/store_sns_save')}" id="recommend_form">
                <input type="hidden" name="type" value="9" />
                <dl>
                    <dt><i class="required">*</i>{$Think.lang.store_sns_goods}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <p>
                            <input type="text" class="text w400" name="goods_url" value="" placeholder="{$Think.lang.store_sns_input_goods_url}" />
                        </p>
                    </dd>
                </dl>
                <dl>
                    <dt><i class="required">*</i>{$Think.lang.store_sns_cotent}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <textarea name="content" class="textarea w400 h100" dstype="recommend" id="content_recommend"></textarea>
                        <p class="w450">
                           <!-- <span class="smile">
                                <a href="javascript:void(0)" ds_type="smiliesbtn" data-param='{"txtid":"recommend"}' class="dssc-btn-mini dssc-btn-orange">
                                <i class="iconfont">&#xe669;</i>{$Think.lang.store_sns_face}</a>
                            </span>-->
                            <span id="weibocharcount_recommend" class="weibocharcount"></span>
                        </p>
                    </dd>
                </dl>
                <div class="bottom">
                    <input type="submit" class="submit" value="{$Think.lang.store_sns_release}" />
                </div>
            </form>
        </div>


        <div class="dssc-form-default" dstype="hotsell" style="display: none;" >
            <form method="post" action="{:url('Sellersns/store_sns_save')}" id="hotsell_form">
                <input type="hidden" name="type" value="10" />
                {notempty name="hotsell_list"}
                <dl>
                    <dt><i class="required">*</i>{$Think.lang.store_sns_hotsell_dt}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <div class="div-goods-select">
                            <div class="search-result" style="width:739px;">
                                <ul class="goods-list" style=" width:760px;">
                                    {foreach name="hotsell_list" item="val"  }
                                    <li>
                                        <div class="goods-thumb"><img src="{:goods_cthumb($val['goods_image'], 240, $val['store_id'])}" /></div>
                                        <dl class="goods-info">
                                            <dt>
                                            <input type="checkbox" class="checkbox" name="goods_id[]" value="{$val.goods_id}" />
                                            {$val.goods_name}</dt>
                                        </dl>
                                    </li>
                                    {/foreach}
                                </ul>
                            </div>
                        </div>
                        <p class="hint">{$Think.lang.store_sns_hotsell_hint}</p>
                    </dd>
                </dl>
                <dl>
                    <dt><i class="required">*</i>{$Think.lang.store_sns_cotent}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <textarea name="content" class="textarea w450" dstype="hotsell" id="content_hotsell"></textarea>
                        <p class="w450">
                            <!--<span class="smile"> <a href="javascript:void(0)" ds_type="smiliesbtn" data-param='{"txtid":"hotsell"}' class="dssc-btn-mini dssc-btn-orange"><i class="iconfont">&#xe669;</i>{$Think.lang.store_sns_face}</a> </span>-->
                            <span id="weibocharcount_hotsell" class="weibocharcount"></span></p>
                    </dd>
                </dl>
                <div class="bottom">
                    <input type="submit" class="submit" value="{$Think.lang.store_sns_release}" />
                </div>
                {else /}
                <div class="warning-option"><i class="iconfont">&#xe64c;&nbsp;</i><span><span>{$Think.lang.store_sns_hotsell_null}
                            <label for="sns_recommend"><a>{$Think.lang.store_sns_self_recommend}</a></label>
                        </span></div>
                {/notempty}
            </form>
        </div>
        <div class="dssc-form-default" dstype="new" style="display: none;" >
            <form method="post" action="{:url('Sellersns/store_sns_save')}" id="new_form">
                <input type="hidden" name="type" value="3" />
                {notempty name="new_list"}
                <dl>
                    <dt><i class="required">*</i>{$Think.lang.store_sns_recommend_dt}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <div class="div-goods-select">
                            <div class="search-result" style="width:739px;">
                                <ul class="goods-list" style=" width:760px;">
                                    {foreach name="new_list" item="val"}
                                    <li>
                                        <div class="goods-thumb"><img src="{:goods_cthumb($val['goods_image'], 240, $val['store_id'])}"/></div>
                                        <dl class="goods-info">
                                            <dt>
                                            <input type="checkbox" class="checkbox" name="goods_id[]" value="{$val.goods_id}" />
                                            {$val.goods_name}</dt>
                                        </dl>
                                    </li>
                                   {/foreach}
                                </ul>
                            </div>
                        </div>
                    </dd>
                </dl>
                <dl>
                    <dt><i class="required">*</i>{$Think.lang.store_sns_cotent}{$Think.lang.ds_colon}</dt>
                    <dd>
                        <textarea name="content" class="textarea w450" dstype="new" id="content_new"></textarea>
                        <p class="w450">
                            <!--<span class="smile"> <a href="javascript:void(0)" ds_type="smiliesbtn" data-param='{"txtid":"new"}' class="dssc-btn-mini dssc-btn-orange"><i class="iconfont">&#xe669;</i>{$Think.lang.store_sns_face}</a> </span>-->
                            <span id="weibocharcount_new" class="weibocharcount"></span></p>
                    </dd>
                </dl>
                <div class="bottom">
                    <input type="submit" class="submit" value="{$Think.lang.store_sns_release}" />
                </div>
                {else /}
                <div class="warning-option"><i class="iconfont">&#xe64c;&nbsp;</i><span>{$Think.lang.store_sns_new_null}
                        <label for="sns_recommend"><a>{$Think.lang.store_sns_self_recommend}</a></label>
                    </span> </div>
                {/notempty}
            </form>
        </div>


<!-- 表情弹出层 -->
<div id="smilies_div" class="smilies-module"></div>
<script>
    jQuery.browser={};(function(){jQuery.browser.msie=false; jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)./)){ jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();
</script>
<script type="text/javascript" src="{$Think.HOME_SITE_ROOT}/js/sns_store.js" charset="utf-8"></script> 
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/smilies/smilies_data.js" charset="utf-8"></script> 
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/smilies/smilies.js" charset="utf-8"></script> 
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.caretInsert.js" charset="utf-8"></script> 
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.charCount.js"></script> 
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.ajaxContent.pack.js"></script> 
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/ajaxfileupload.js"></script> 
<script>
$(function(){
        /* ajax添加商品  */
        $('a[dstype="get_img"]').ajaxContent({
                event:'click', //mouseover
                loaderType:"img",
                loadingMsg:'{$Think.HOME_SITE_ROOT}/images/transparent.gif',
                target:'#get_img_ajaxContent'
        }).click(function(){
            $(this).hide();
            $('a[dstype="del_img"]').show();
    });
    $('a[dstype="del_img"]').click(function(){
        $(this).hide();
        $('a[dstype="get_img"]').show();
        $('#get_img_ajaxContent').html('');
    });
	
        $('body').click(function(){ $("#smilies_div").html(''); $("#smilies_div").hide();});
        $('input[name="sns_type"]').each(function(){
                if($(this).prop('checked')){
                        $('.dssc-form-default').hide();
                        $('.dssc-form-default[dstype="'+$(this).val()+'"]').show();
                }
        });
        $('input[name="sns_type"]').change(function(){
                $('.dssc-form-default').hide();
                $('.dssc-form-default[dstype="'+$(this).val()+'"]').show();
        });

        $('textarea[name="content"]').each(function(){
                $(this).charCount({
                        allowed: 140,
                        warning: 10,
                        counterContainerID:	'weibocharcount_'+$(this).attr('dstype'),
                        firstCounterText:	'{$Think.lang.sns_charcount_tip1}',
                        endCounterText:		'{$Think.lang.sns_charcount_tip2}',
                        errorCounterText:	'{$Think.lang.sns_charcount_tip3}'
                });
        });

        $('#normal_form').validate({
                errorLabelContainer: $('#warning'),
                invalidHandler: function(form, validator) {
                        $('#warning').show();
                },
                submitHandler:function(form){
                        ds_ajaxpost('normal_form')
                },
                rules : {
                        content : {
                                required : true
                        }
                },
                messages : {
                        content : {
                                required : '{$Think.lang.store_sns_content_not_null}'
                        }
                }
        });
    
        $('#recommend_form').validate({
                errorLabelContainer: $('#warning'),
                invalidHandler: function(form, validator) {
                        $('#warning').show();
                },
                submitHandler:function(form){
                        ds_ajaxpost('recommend_form')
                },
                rules : {
                        content : {
                                required : true
                        },
                        goods_url : {
                                required : true,
                        }
                },
                messages : {
                        content : {
                                required : '{$Think.lang.store_sns_content_not_null}'
                        },
                        goods_url : {
                                required : '{$Think.lang.store_sns_input_goods_url}',
                        }
                }
        });
    
        $('#hotsell_form').validate({
                errorLabelContainer: $('#warning'),
                invalidHandler: function(form, validator) {
                        $('#warning').show();
                },
                submitHandler:function(form){
                        // 验证是否选中商品
                        if($('#hotsell_form').find('input[type="checkbox"]:checked').length == 0){
                                $('#hotsell_form').find('ul').after('<label class="error" for="content" generated="true">{$Think.lang.store_sns_choose_goods}</label>');
                                return false;
                        }else{
                                $('#hotsell_form').find('ul').next('label').remove();
                        }
                        ds_ajaxpost('hotsell_form')
                },
                rules : {
                        content : {
                                required : true
                        }
                },
                messages : {
                        content : {
                                required : '{$Think.lang.store_sns_content_not_null}'
                        }
                }
        });
    
        $('#new_form').validate({
                errorLabelContainer: $('#warning'),
                invalidHandler: function(form, validator) {
                        $('#warning').show();
                },
        submitHandler:function(form){
                // 验证是否选中商品
                        if($('#new_form').find('input[type="checkbox"]:checked').length == 0){
                                $('#new_form').find('ul').after('<label class="error" for="content" generated="true">{$Think.lang.store_sns_choose_goods}</label>');
                                return false;
                        }else{
                                $('#new_form').find('ul').next().remove('label');
                        }
                ds_ajaxpost('new_form')
        },
                rules : {
                        content : {
                                required : true
                        }
                },
                messages : {
                        content : {
                                required : '{$Think.lang.store_sns_content_not_null}'
                        }
                }
        });

        // 图片上传js
        $('#normal_file').unbind().on('change', function(){
                $('img[dstype="normal_img"]').attr('src','{$Think.HOME_SITE_ROOT}/images/loading.gif');

                $.ajaxFileUpload
                (
                        {
                                url:'{:url("Sellersns/image_upload")}',
                                secureuri:false,
                                fileElementId:'normal_file',
                                dataType: 'json',
                                data:{id:'normal_file'},
                                success: function (data, status)
                                {
                                        if(typeof(data.error) != 'undefind'){
                                                $('img[dstype="normal_img"]').attr('src',data.image);
                                                $('#sns_image').val(data.image);
                                        }else{
                                                alert(data.error);
                                        }
                                },
                                error: function (data, status, e)
                                {
                                        alert(e);
                                }
                        }
                )
                return false;

        });
});
//从图片空间中插入图片
function sns_insert(data){
        $('img[dstype="normal_img"]').attr('src',data);
        $('#sns_image').val(data);
}
</script>

{/block}
